/*
 * Copyright 2008 Mark Davidson.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package org.doofer

/**
 * Bootstraps the DFC extensions and provides access to factory
 * methods.
 *
 * @author Mark Davidson
 */
class Doofer {

    private def newSessionUtil = { Map params -> new SessionUtil(params) }
    private def queryUtil = QueryUtil.newInstance()
    private def attribUtil = AttribUtil.newInstance()
    private def contentUtil = ContentUtil.newInstance()
    private def objectUtil = ObjectUtil.newInstance()

    /**
     * Constructor
     */
    Doofer() {}

    /**
     * Returns a new SessionUtil instance. The named parameters are:
     *
     * <ul>
     * <li>username - the username to connect as</li>
     * <li>password - the password</li>
     * <li>repository - the repository/docbase to connect to</li>
     * </ul>
     *
     * @param params the map of named parameters (@see SessionUtil)
     * @return A SessionUtil instance
     */
    def getSessionUtil(Map params) { newSessionUtil(params) }

    /**
     * Returns a new QueryUtil instance
     *
     * @return A QueryUtil instance
     */
    def getQueryUtil() { queryUtil }

    /**
     * Returns a new AttribUtil instance
     *
     * @return A AttribUtil instance
     */
    def getAttribUtil() { attribUtil }

    /**
     * Returns a new ContentUtil instance
     *
     * @return A ContentUtil instance
     */
    def getContentUtil() { contentUtil }

    /**
     * Returns a new ObjectUtil instance
     *
     * @return A ObjectUtil instance
     */
    def getObjectUtil() { objectUtil }

    /**
     * Bootstrap DFC extensions
     */
    static {
        new Bootstrap().boot()
    }
}